$(document).ready(function () {
    $("#b_login").click(function () {
        var name=$("#username").val();
        var password=$("#password").val();
        var user={name:"",password:""};
        user.name=name;
        user.password=password;
        $.ajax({
            url: path+"/user/checkLogin",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(user),
            dataType: "json",
            success: function (data) {
                if("teacher"==data.msg){
                    window.location.href = path+"/Tmain";
                    return;
                }else if("false1"==data.msg) {
                    alert("用户名不存在！");
                }
                else if("false2"==data.msg){
                    alert("用户名和密码不匹配！");
                }
                else if("student"==data.msg){
                    window.location.href = path+"/Smain";
                    return;
                }
            },
            fail: function (err) {
                console.log(err)
            }
        })

    });

});
$(document).keyup(function(event){
    if(event.keyCode ==13){
        $("#b_login").trigger("click");
    }
});
